package com.yvon.maple.service.base.service;

import com.yvon.boot.mybatis.IBaseService;
import com.yvon.maple.service.base.entity.FileInfo;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;


/**
 * 文件信息服务
 *
 * @author : Yvon
 * @since : 2022/08/13
 */
public interface FileInfoService extends IBaseService<FileInfo> {

	/**
	 * 上传文件
	 *
	 * @param file 文件
	 * @return : FileInfo
	 * @author : Yvon / 2020-11-03
	 */
	FileInfo putFile(MultipartFile file);

	/**
	 * 把视频
	 *
	 * @param video 视频
	 * @return {@code FileInfo }
	 */
	FileInfo putVideo(MultipartFile video);


	/**
	 * 查询文件流
	 *
	 * @param fileInfo 文件信息
	 * @return : InputStream
	 * @author : Yvon / 2020-11-04
	 */
	InputStream getFileStream(FileInfo fileInfo) throws Exception;


	/**
	 * 批量上传文件
	 *
	 * @param files 文件
	 * @return : List<FileInfo>
	 * @author : Yvon / 2020-11-05
	 */
	List<FileInfo> putFiles(List<MultipartFile> files);


	/**
	 * 临时的url
	 *
	 * @param businessKeys 业务键
	 * @param hour         小时
	 * @return List<String>
	 * @author : Yvon / 2021-10-22
	 */
	List<String> tempUrl(Set<String> businessKeys, Integer hour);


	/**
	 * 临时的url
	 *
	 * @param id   ID
	 * @param hour 小时
	 * @return List<String>
	 * @author : Yvon / 2021-10-22
	 */
	List<String> getTempUrl(Set<Long> id, Integer hour);

    /**
     * 临时的url
     *
     * @param id id
     * @param hour         小时
     * @return List<String>
     * @author : Yvon / 2021-10-22
     */
    String getTempUrl(Long id, Integer hour);

    List<FileInfo> getFileInfo(Set<String> businessKeys, Integer hours);

    Boolean incrSave(Set<Long> fileIds, String businessKey);

    Boolean coverSave(Set<Long> fileIds, String businessKey);

    List<String> getTempUrlByBusiness(Set<String> businessKeys, Integer hours);

	Map<String, List<String>> tempUrlMap(Set<String> businessKeys, Integer hours);
}
